package com.xinzhi.service;

public class BankServiceImpl {
    public static class BankAccount {

        private double balance;

        public BankAccount(double balance) {
            this.balance = balance;
        }

        public double getBalance() {
            return balance;
        }

        public void deposit(double amount) {
            if (amount <= 0) {
                throw new IllegalArgumentException("存款金额必须大于零");
            }
            balance += amount;
        }

        public void withdraw(double amount) {
            if (amount <= 0) {
                throw new IllegalArgumentException("提现金额必须大于零");
            }
            if (amount > balance) {
                throw new IllegalArgumentException("余额不足，当前余额：" + balance);
            }
            balance -= amount;
        }
    }

}





